<?php // this must be the very first line in your PHP file!

require '../../../include/library.inc.php';
require '../../../include/admin_login.inc.php';

$sql = "SELECT
			c.order_number,
			c.sef_url,
			
			d.title
			
			
		FROM
			catalog AS c,
			catalog_description AS d
		WHERE
		
			c.catalog_id = d.catalog_id
			
			AND
			
			d.lang_id = '1'
			
			AND c.published
			
			ORDER BY c.order_number DESC
		  ";
   
  $result = query($sql);

// You can't simply echo everything right away because we need to set some headers first!
$output = ''; // Here we buffer the JavaScript code we want to send to the browser.
$delimiter = "\n"; // for eye candy... code gets new lines

$output .= 'var tinyMCELinkList = new Array(';

  while ($row = mysql_fetch_object($result)) {		
        
		$output .= $delimiter
			. '["'
			. $row->title
			. '", "'
			. HTML_BASE."product/".$row->sef_url
			. '"],';
    }

    $output = substr($output, 0, -1); // remove last comma from array item list (breaks some browsers)
    $output .= $delimiter;


// Finish code: end of array definition. Now we have the JavaScript code ready!
$output .= ');';

// Make output a real JavaScript file!
header('Content-type: text/javascript'); // browser will now recognize the file as a valid JS file

// prevent browser from caching
header('pragma: no-cache');
header('expires: 0'); // i.e. contents have already expired

// Now we can send data to the browser because all headers have been set!
echo $output;

?>